<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<script type="text/javascript">
function addNewTask(id){
	$.blockUI();
	$.post('./task/startTask.action', {'idProject':id}, function(respuestaHTML) {
				$('#content').html(respuestaHTML);
			});
	}
	
function modifyProject(id){
	$.post('./project/modifyProject.action', {'id':id}, function(respuestaHTML) {
				$('#content').html(respuestaHTML);
			});
	}
	
function addUsers(idProyecto){
	$.blockUI();
	$.post('./project/loadUsersProjectList.action', {'id':idProyecto}, function(respuestaHTML) {
				$('#addUserForm').html(respuestaHTML);
			});
	$('#addUserForm').show();
	}
	
function cancelAdduser(){
	$('#addUserForm').hide();
	}	
	
function confirmOperation(operation) {
	return confirm("Desea " + operation + "?");
}

function viewTask(id_){
	$.post('./task/viewTask.action',{id:id_},function(resultadoHTML) {
		$('#content').html(resultadoHTML);
	});
}

function modifyTask(id_){
	$.post('./task/modifyTask.action',{id:id_},function(resultadoHTML) {
		$('#content').html(resultadoHTML);
	});
}
</script>

<div class="page-header">
  <h1> Project ID:<s:property value="project.id" /></h1>
</div>
<table class="table table-striped">
	<thead>
		<tr>
			<th>ID</th>
			<th>PROJECT NAME</th>
			<th>LEADER</th>
			<th>HOURS</th>
			<th>START DATE</th>
			<th>END DATE</th>
			<th>OPTIONS</th>
		</tr>
	</thead>
	<tr>
		<td><s:property value="project.id" /></td>
		<td><s:property value="project.name" /></td>
		<td><s:property value="project.leader.lastName" /></td>
		<td><s:property value="project.hours" /></td>
		<td><s:property value="project.period.startDate" /></td>
		<td><s:property value="project.period.endDate" /></td>
		<td><a href="#" onclick="modifyProject(<s:property value="id" />)"class="btn btn-mini btn-info"><i class="icon-pencil"></i>edit</a></td>
	</tr>
</table>
<s:property value="msg"/>

<div class="page-header">
  <h2>Project Team </h2>
</div>

<table class="table table-striped table-condensed">
	<thead>
		<tr>
			<th>Id</th>
			<th>Name</th>
			<th>Last name</th>
			<th>Options</th>
		</tr>
	</thead>
	<s:iterator value="project.projectUsers">
	<tr>
		<s:if test = "active == 1">
			<td><s:property value="userPerson.id" /></td>
			<td><s:property value="userPerson.name"/></td>
			<td><s:property value="userPerson.lastName"/></td>
			<td>
				<a class="btn btn-mini" href="#" onclick="assignTask(<s:property value="id" />)">Assign Task</a>
			</td>
		</s:if>
	<tr/>
	</s:iterator>
	
</table>
<a Class="btn btn-small" href="#" onclick="addUsers(<s:property value="project.id" />)"><i class="icon-plus"></i>Add users</a><br><br>
<div id="addUserForm"></div>
<div class="page-header">
  <h2>Project Tasks</h2>
</div>

<table class="table table-striped table-condensed">
	<thead>
	<tr>
		<th>Id</th>
		<th>title</th>
		<th>hours</th>
		<th>Options</th>
	</tr>
	</thead>
	<s:iterator value="project.tasks">
	<tr>	
		<td><s:property value="id" /></td>
		<td><s:property value="title"/></td>
		<td><s:property value="hours"/></td>
		<td>
			<a href="#" onclick="viewTask(<s:property value="id" />)" class="btn btn-mini"><i class="icon-search"></i>view</a>
			<a href="#" onclick="modifyTask( <s:property value="id" />)" class="btn btn-mini  btn-info"><i class="icon-pencil"></i>edit</a>
		</td>
	<tr/>
	</s:iterator>
</table>
<a Class="btn btn-small" href="#" onclick="addNewTask(<s:property value="project.id" />)"><i class="icon-plus"></i>Add new task</a>

